﻿{include file="public/header"}

</head>
<body>
<nav class="breadcrumb">
    <i class="Hui-iconfont">&#xe67f;</i> 首页
    <span class="c-gray en">&gt;</span> 店铺管理
    <span class="c-gray en">&gt;</span> 店铺列表
    <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新"><i class="Hui-iconfont">&#xe68f;</i></a>
</nav>
<div class="page-container">
    <a style="text-decoration:none" class="btn btn-primary add "  href="javascript:;" title="新增"><span class="label label-primary">新增</span></a>
    <div class="mt-20">
        <div class="title-border">
            <div class="flex2">序号</div>
            <div class="flex2">店铺名称</div>
            <div class="flex5">店铺地址</div>
            <div class="flex3">操作</div>
        </div>
        {volist name='list' id='vo'}
        <div class="content-border">
            <div class="flex2">{$vo.store_id}</div>
            <div class="flex2">{$vo.store_name}</div>
            <div class="flex5">{$vo['province_id'].$vo['city_id'].$vo['county_id'].$vo['addres']}</div>
            <div class="flex3">
                    <a class="ch-button ch-blue edit" data-id="{$vo.store_id}" href="javascript:;" title="编辑">编辑</a>
                    <a class="ch-button ch-red del" data-id="{$vo.store_id}" href="javascript:;" title="删除">删除</a>        
            </div>
        </div>
        {/volist}

        <div class="pages" style="float: right">{$list->render()}</div>

    </div>
</div>

{include file="public/footer"}
<script type="text/javascript">
    /**
     * 添加店铺
     */
    $('.add').click(function () {
        var winWidth = $(window).width();
        var areaWidth = "";
        var areaHeight = "";
        if( winWidth > 768 ){
            areaWidth = "600px"
            areaHeight = "350px"
        } else {
            areaWidth = '100%'
            areaHeight = '100%'
        }
        var id=$(this).attr('data-id');
        var src="{:Url('index/need/add')}";
        layer.open({
            type: 2,
            area: [areaWidth, areaHeight],
            title: '添加店铺',
            content: src
        });
    });

    /**
     * 删除
     */
    $('.del').click(function () {
        var id=$(this).attr('data-id');
        var obj={};
        obj.store_id=id;
        var src="{:Url('index/need/del')}";
        layer.confirm('确认要删除吗？', function (index) {
            $.ajax({
                type: 'POST',
                url: src,
                dataType: 'json',
                data: obj,
                success: function (data) {
                    var res=JSON.parse(data);
                    if(res.code==200){
                        layer.msg(res.msg, {icon: 1, time: 2000}, function () {
                            setTimeout("window.location.reload()", 1);
                        });
                    }else{
                        layer.msg(res.msg,{icon: 5,time:1000});
                    }

                },
                error: function (data) {
                    console.log(data.msg);
                },
            });
        });
    });
    $('.edit').click(function () {
        var winWidth = $(window).width();
        var areaWidth = "";
        var areaHeight = "";
        if( winWidth > 768 ){
            areaWidth = "600px"
            areaHeight = "350px"
        } else {
            areaWidth = '100%'
            areaHeight = '100%'
        }
        var id=$(this).attr('data-id');
        var src="{:Url('index/need/edit')}";
        layer.open({
            type: 2,
            area: [areaWidth, areaHeight],
            title: '编辑',
            content: src+'?store_id='+id
        });
    });
</script>
</body>
</html>